package com.shigen.file.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import java.util.Collections;

/**
 * mybatis-plus代码生成器
 *
 * @author shigenfu
 * @date 2022/6/4 4:19 下午
 */
public class CodeGenerator {
    private static final String URL = "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai";
    private static final String USERNAME ="root";
    private static final String PASSWORD = "123456";

  public static void main(String[] args) {
    FastAutoGenerator.create(URL, USERNAME, PASSWORD)
        .globalConfig(builder -> {
          builder.author("shigen.fu") // 设置作者
              .enableSwagger() // 开启 swagger 模式
              .fileOverride() // 覆盖已生成文件
              .outputDir("/Users/shigenfu/IdeaProjects/shigen-file/shigen-file-repository/src/main/java"); // 指定输出目录
        })
        .packageConfig(builder -> {
          builder.parent("com.shigen") // 设置父包名
              .moduleName("file") // 设置父包模块名
              .pathInfo(Collections.singletonMap(OutputFile.xml, "/Users/shigenfu/IdeaProjects/shigen-file/shigen-file-repository/src/main/resources")); // 设置mapperXml生成路径
        })
        // .strategyConfig(builder -> {
        //   builder.addInclude("t_simple") // 设置需要生成的表名
        //       .addTablePrefix("t_", "c_"); // 设置过滤表前缀
        // })
        .execute();
  }

}
